package com.example.prison.mapper;

import com.example.prison.entity.AreaRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author jiang
* @description 针对表【area_record】的数据库操作Mapper
* @createDate 2023-06-07 10:30:19
* @Entity com.example.prison.entity.AreaRecord
*/
@Mapper
public interface AreaRecordMapper extends BaseMapper<AreaRecord> {

    @Select("select * from area_record order by id desc")
    List<AreaRecord> get();

//    @Insert("insert into area_record(defense_section,defense_section_point, time,alarm_level,voltage,negative_voltage,current,rated_voltage,alarm_status,device_number,sentry_post,sentry_address) " +
//            "values (#{defenseSection},#{defenseSectionPoint},#{time},#{alarmLevel},#{voltage},#{negativeVoltage},#{current},#{ratedVoltage},#{alarmStatus},#{deviceNumber},#{sentryPost},#{sentryAddress})")
    @Insert("insert into area_record(defense_section, defense_section_point, sentry_post, sentry_address, time, alarm_level, " +
            "voltage1,status1,voltage2,status2,battery_voltage,battery_t,air,in_voltage, " +
            "alarm_status, device_number) " +
            "values (#{defenseSection}, #{defenseSectionPoint}, #{sentryPost}, #{sentryAddress}, #{time}, #{alarmLevel}, " +
            "#{voltage1},#{status1},#{voltage2},#{status2},#{batteryVoltage},#{batteryT},#{air},#{inVoltage}, " +
            "#{alarmStatus}, #{deviceNumber})")
    int add(AreaRecord record);

    @Select("select * from area_record where defense_section like concat('%',#{defenseSection},'%') order by id desc")
    List<AreaRecord> getByDefenseSection(@Param("defenseSection") String defenseSection);

    @Select("select * from area_record where alarm_status like concat('%',#{alarmStatus},'%') order by id desc")
    List<AreaRecord> getByAlarmStatus(@Param("alarmStatus") String alarmStatus);

    @Select("select * from area_record where device_number like concat('%',#{deviceNumber},'%') order by id desc")
    List<AreaRecord> getByDeviceNumber(@Param("deviceNumber") String deviceNumber);

    @Select("select * from area_record where time between #{beginTime} and #{endTime} order by id desc")
    List<AreaRecord> getByTime(@Param("beginTime") String beginTime, @Param("endTime") String endTime);


}




